import React from 'react'
import { Button, Form, Input, Modal, Select, Switch } from 'antd'

function FormSubmit({open, form, sbumitFN, title, closeFn}) {
    const onFinish = (values) => {
        sbumitFN({
            id: values.id,
            name: values.name,
            job: values.job,
            status: values.status ? 1 : 0
        })
    }
  return (
    <Modal open={open} onCancel={closeFn} title={title} footer={null}>
      <Form 
        form={form} 
        onFinish={onFinish}
      >
        <Form.Item name="id" hidden>
            <Input />
        </Form.Item>
        <Form.Item name="name">
            <Input placeholder="输入用户名" />
        </Form.Item>
        <Form.Item name="job" label="岗位">
            <Select>
                <Select.Option value="销售员">销售员</Select.Option>
                <Select.Option value="销售助理">销售助理</Select.Option>
                <Select.Option value="总经理">总经理</Select.Option>
            </Select>
        </Form.Item>
        <Form.Item name="status" label="状态">
            <Switch />
        </Form.Item>
        <Form.Item>
            <Button htmlType='submit'>提交</Button>
        </Form.Item>
      </Form>
    </Modal>
  )
}

export default React.memo(FormSubmit)
